<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Mod_crop extends CI_Controller {
	function __construct() {
		parent::__construct();
	}
	function index() {
		$data['content'] = $this->load->view('mod_crop/views_crop.php', array(
			'images' => $this->session->userdata('dataimages')
		), true);
		$this->load->view('index', $data);
	}
	function cropanh() {
		$fullpatch  = $this->input->post('fulloatch');
		$nameimages = $this->input->post('nameimages');
		$width      = $this->input->post('w');
		$height     = $this->input->post('h');
		$x_xis      = $this->input->post('x');
		$y_xis      = $this->input->post('y');
		$x2_xis     = $this->input->post('x2');
		$y2_xis     = $this->input->post('y2');
		$config     = array(
			'source_image' => $fullpatch,
			'maintain_ratio' => false,
			'x_axis' => $x_xis,
			'y_axis' => $y_xis,
			'width' => $width,
			'height' => $height
		);
		$this->load->library('image_lib', $config);
		if (!$this->image_lib->crop()) {
			echo $this->image_lib->display_errors();
		} else {
			$images2 = $this->session->userdata('dataimages');
			$this->session->set_userdata('images', $images2['file_name']);
			$this->session->unset_userdata('dataimages');
			redirect(base_url() . 'dang-ky/buoc2');
		}
	}
}
?>